<template>
<el-form-item :label="label">
    <!-- {{landDataPropsCode}} -->
    <el-cascader v-model="landDataPropsCode" :options="options" :props="{ multiple: false, checkStrictly: true,value:'landTypeCode', label:'landTypeName'}" clearable></el-cascader>
</el-form-item>
</template>

<script>
export default {
    props: {
        label: {
            type: String,
            default: function () {
                return '地块类型'
            }
        },
        landPropsCode: [String, Array, Number]
    },
    data() {
        return {
            options: [],
        }
    },
    created() {
        this.getLandTypeList()
    },
    computed: {
        landDataPropsCode: {
            get() {
                if (this.landPropsCode instanceof Array) {
                    return this.landPropsCode
                } else {
                    let landTypeCode = []
                    landTypeCode.push(String(this.landPropsCode).substring(0, 2))
                    landTypeCode.push(String(this.landPropsCode))
                    return landTypeCode
                }
            },
            set(arr) {
                this.$emit("on-success", arr)
                this.landPropsCode = arr
            }
        }
    },
    methods: {
        getLandTypeList() {
            this.$common.getLandType()
                .then((res) => {
                    this.options = res.data.list
                });
        },
    },
}
</script>
